package cn.com.thinvent.dispatch.service.biz.impl;

import cn.com.thinvent.dispatch.dao.PdfFileMapper;
import cn.com.thinvent.dispatch.entity.file.contentVo;
import cn.com.thinvent.dispatch.entity.file.filevo;
import cn.com.thinvent.dispatch.entity.file.tagVo;
import cn.com.thinvent.dispatch.service.biz.PdfFile;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PdfFileImpl implements PdfFile {
    @Resource
    private PdfFileMapper pdfFileMapper;

    @Override
    public Long insertPdfContent(contentVo vo) {
        long r = pdfFileMapper.insertfilecontent(vo);
        return r;
    }

    @Override
    public Long insertPdf(filevo vo) {
        long r = pdfFileMapper.insertfile(vo);
        return r;
    }

    public String getOrSetTag(String tag) {
        List<tagVo> res1 = pdfFileMapper.getTag(tag);
        tagVo vo = new tagVo();
        if(res1.size() == 0){
            vo.setTag(tag);
            pdfFileMapper.insertTag(vo);
        }else{
            vo.setTagId(res1.get(0).getTagId());
        }
        return vo.getTagId();
    }
}
